@extends('layout')
@section('content')
<div class="bloque row color2">
    <center><h5>REPORTE DE GANANCIAS</h5></center>
</div>
@if(! isset($detalledatos))
<div class="bloque row">
    <strong>{{'REGISTRO DE GANANCIAS:  '}}</strong>{{'Selecione las fechas para Mostrar los Registros'}}
</div>
@endif
<div class="bloque">
    {{ Form::open(array('url' => 'ganancias', 'method' => 'post'))}}
        <div class = "row">
            <div class = 'col-md-4'>
                <br>
                <div class="input-group">
                    <div class="input-group-addon"><strong>Desde:</strong><i class="fa fa-calendar"></i></div>
                    {{Form::input('date','fecha_desde', null, array('class'=>'form-control','required'))}}
                </div>
                <br>
            </div>
            <div class = 'col-md-4'>
                <br>
                <div class="input-group">
                    <div class="input-group-addon"><strong>Hasta:</strong><i class="fa fa-calendar"></i></div>
                    {{Form::input('date','fecha_hasta', null, array('class'=>'form-control','required'))}}
                </div>
                <br>
            </div>
            <div class = 'col-md-4'>
                <br>
                <center>{{Form::button('buscar', array('type' => 'submit', 'class' => 'btn btn-primary'))}}</center>
                <br>
            </div>
        </div>
    {{Form::close()}}
</div>
@if(isset($detalledatos))
    <div class="bloque row">
        <div class="col-md-12" style="padding-left: 0px;padding-right: 0px;">
            <input type="text" class="form-control" id="yo" data-action="filter" data-filters="#dev-table" placeholder="Filtrar Ganado" />
        </div>
    </div>
    <div class="bloque">
        <div class="table-responsive">
            <table class="table-bordered table-hover" id="dev-table">
                <thead> 
                    <tr class="active" >
                        <th width="100px">Fecha de Ingreso</th>
                        <th width="100px">Fecha de Venta</th>
                        <th>C&oacute;digo de res</th>
                        <th>Sexo</th>
                        <th>Color</th>
                        <th>Raza</th>
                        <th width="100px">Costo x Kg (Compra)</th>
                        <th>Peso en Kg  (Compra)</th>
                        <th>Precio Total (Compra)</th>
                        <th width="100px">Costo x Kg (Venta)</th>
                        <th>Peso en Kg  (Venta)</th>
                        <th>Precio Total (Venta)</th>
                        <th width="100px">Ganancia</th>
                        <th>D&iacute;as de cr&iacute;a</th>
                        <th>Ganancia por d&iacute;a</th>

                    </tr>
                </thead>
                <tbody> 
                    {{--*/$total_ganancias = 0;$totalxdias=0;/*--}}
                    @foreach($detalledatos as $detalles)

                    <tr>
                        <center></center>
                        <td width="100px"><center>{{$detalles->fecha_nacimiento}}</center></td>
                        <td width="100px"><center>{{$detalles->fecha}}</center></td>
                        <td><center>{{$detalles->cod_ganado}}</center></td>
                        <td><center>{{$detalles->sexo}}</center></td>
                        <td><center>{{$detalles->color}}</center></td>
                        <td><center>{{$detalles->raza}}</center></td>
                        <td class="info"><center>{{$detalles->costo_kilo}}</center></td>
                        <td class="info"><center>{{$detalles->peso_kilo}}</center></td>
                        <td class="info"><center>${{$detalles->costo_bruto}}</center></td>
                        <td class="warning"><center>{{number_format($detalles->precio_kilo,2,'.','')}}</center></td>
                        <td class="warning"><center>{{$detalles->peso}}</center></td>
                        <td class="warning"><center>${{number_format($detalles->precio_bruto,2,'.','')}}</center></td>
                        <td><center>${{number_format($detalles->ganancia,2,'.','')}}</center></td>
                        <td><center>{{$detalles->dias}}</center></td>
                        <td><center>${{$detalles->ganancias_dias}}</center></td>
                        {{--*/$total_ganancias =  $total_ganancias + $detalles->ganancia;/*--}}
                        
                        {{--*/
                          $totalxdias= $totalxdias + ($detalles->ganancias_dias*1);/*--}}
                    </tr>
                    @endforeach
                </tbody>
                    <tr class="active">
                        <th colspan="12"><span class="pull-right">TOTAL</span></th>
                        <th>{{number_format($total_ganancias,2,'.','')}}</th>
                        <th></th>
                        <th>{{number_format($totalxdias,2,'.','')}}</th>
                    </tr>
            </table>
        </div>
    </div>
@endif
    
@stop
@section('mensaje')
    @if(isset($mensaje))
        <div class="bloque color3">
            {{$mensaje}}
        </div>
    @endif
@stop
@section('modal')
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      

    </div>
  </div>
</div>
@stop